import pymysql.cursors

# 连接数据库
conn = pymysql.Connect(
    host='47.94.130.233',
    port=3306,
    user='root',
    passwd='123456',
    db='ssm',
    charset='utf8',
)
# print(conn)
# 获取游标
my_cursor = conn.cursor()
# 准备SQL
sql = 'select * from student where cid = %s order by id desc limit %s,%s'
# 准备插入的数据
values = (2, 2, 5)
# 执行SQL
my_cursor.execute(sql, values)
# 获取所有记录
rs = my_cursor.fetchall()
# 关闭连接
conn.close()

for x in rs:
    print(x)
